package com.kristin.thread.thread.see;

import java.io.IOException;

// 线程的可见性示例
public class ThreadViewable {

    public static boolean flag = true;

    public static class T1 extends Thread {

        public void run() {
            System.out.println("thread start");
            while(flag) {
                System.out.println("hello");
            }
            System.out.println("thread end");
        }

    }

    public static void main(String[] args) throws InterruptedException, IOException {

        T1 t1 = new T1();
        t1.start();

        Thread.sleep(1000);

        flag = false;

        System.in.read();

    }

}
